package com.cy.system.config;

import org.apache.log4j.Logger;

public class DataSourceContextHolder {
	private final static Logger logger = Logger.getLogger(DataSourceContextHolder.class);
	private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
	
	public static void setDbType(String dbType) {
		logger.info("==> 设置数据源为["+dbType+"]");
		contextHolder.set(dbType);
	}
	
	public static String getDbType() {
		logger.info("==> 获取数据源["+contextHolder.get()+"]");
		return contextHolder.get();
	}
	
	public static void clearDbType() {
		logger.info("==> 清除数据源设置，使用默认数据源！");
		contextHolder.remove();
	}
	
}
